package com.devilwwj.http.entities;

import android.util.JsonReader;

import com.devilwwj.http.exception.HttpException;

import java.io.IOException;

/**
 * Created by devilwwj on 15/8/9.
 */
public class Module implements IEntity{
    public String name;
    public long timestamp;

    @Override
    public void readFromJson(JsonReader reader) throws HttpException {
       try {
           reader.beginObject();
           String node;
           while(reader.hasNext()) {
               node = reader.nextName();
               if ("name".equalsIgnoreCase(node)) {
                   name = reader.nextString();
               } else  if ("timestamp".equalsIgnoreCase(node)) {
                   reader.skipValue();
               }
           }
           reader.endObject();

       } catch (IOException e) {
           throw new HttpException(HttpException.ErrorType.JSON, e.getMessage());
       }
    }
}
